﻿
@{
    ViewBag.Title = "收据分配配置";
    Layout = "~/Views/Shared/_Index.cshtml";
}
<div class="topPanel">
    <div class="toolbar">
        <div class="btn-group">
            <a id="NF-add" class="btn btn-primary dropdown-text" onclick="btn_add()"><i class="fa fa-plus"></i>新建</a>
        </div>
        <div class="btn-group">
            <a id="NF-edit" class="btn btn-primary dropdown-text" onclick="btn_edit()"><i class="fa fa-pencil-square-o"></i>修改信息</a>
        </div>
        <div class="btn-group">
            <a id="NF-delete" class="btn btn-primary dropdown-text" onclick="btn_delete()"><i class="fa fa-trash-o"></i>删除信息</a>
        </div>
    </div>
    <div class="search">
        <table>
            <tr>
                <td>
                    <div class="input-group">
                        <input id="txt_keyword" type="text" class="form-control" placeholder="领用人员" style="width: 200px;">
                        <span class="input-group-btn">
                            <button id="btn_search" type="button" class="btn  btn-primary"><i class="fa fa-search"></i></button>
                        </span>
                    </div>
                </td>
            </tr>
        </table>
    </div>
</div>
<div class="gridPanel">
    <table id="gridList"></table>
</div>

<script>
    $(function () {
        initControl();
        gridList();
    });
    function gridList() {
        var $gridList = $("#gridList");
        $gridList.dataGrid({
            url: "@Url.Action("GetFinancialInvoiceList")",
            height: 400,
            colModel: [
                { label: 'cwsjId', name: 'cwsjId', hidden: true },
                { label: '领用人员', name: 'ry', width: 100, algin: 'left' },
                { label: '首字母', name: 'szm', width: 100, algin: 'left' },
                { label: '当前发票号', name: 'dqsjh', width: 100, algin: 'left' },
                { label: '起始发票号', name: 'qssjh', width: 100, algin: 'left' },
                { label: '结束发票号', name: 'jssjh', width: 100, algin: 'left' },
                {
                    label: '有效', name: 'zt', width: 100, algin: 'left',
                    formatter: function (cellvalue) {
                        if (cellvalue == 0) {
                            return "否";
                        } else {
                            return "是";
                        }
                    }
                },
                {
                    label: '建档日期', name: 'CreateTime', width: 100, align: 'left',
                    formatter: "date", formatoptions: { srcformat: 'Y-m-d', newformat: 'Y-m-d' }
                }
            ]
        });
        $("#btn_search").click(function () {
            $gridList.jqGrid('setGridParam', {
                postData: { keyword: $("#txt_keyword").val() }, url: "@Url.Action("GetFinancialInvoiceList")"
            }).trigger('reloadGrid');
        })
    }

    function initControl() {

    }

    function btn_add() {
        $.modalOpen({
            id: "FormFIEdit",
            title: "发票配置维护",
            url: "@Url.Action("Form")",
            width: "700px",
            height: "500px",
            callBack: function (iframeId) {
                top.frames[iframeId].submitForm();
            }
        });
    }
    //修改
    function btn_edit() {
        var seleRowid = jQuery("#gridList").jqGrid("getGridParam", "selrow");
        if (!(seleRowid)) {
            $.modalAlert("请选中一条信息", 'warning');
            return;
        }
        var Id = $("#gridList").jqGridRowValue().cwsjId;
        $.modalOpen({
            id: "FormFIEdit",
            title: "修改信息",
            url: "/SystemManage/FinancialReceipt/Form?Id=" + Id,
            width: "700px",
            height: "500px",
            callBack: function (iframeId) {
                top.frames[iframeId].submitForm();
            }
        });
    }
    //删除
    function btn_delete() {
        var seleRowid = jQuery("#gridList").jqGrid("getGridParam", "selrow");
        if (!(seleRowid)) {
            $.modalAlert("请选中一条信息", 'warning');
            return;
        }
        var Id = $("#gridList").jqGridRowValue().cwsjId;
        $.deleteForm({
            url: "@Url.Action("DeleteForm")",
            param: { Id: Id },
            success: function () {
                $("#gridList").trigger("reloadGrid");
            }
        })
    }
</script>

